﻿using BanquetGift.DataBases;
using BanquetGift.Dto;
using BanquetGift.Models;
using BanquetGift.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace BanquetGift.Controllers
{
    /// <summary>
    /// 数据字典
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class DataDictionaryController : ControllerBase
    {
        private readonly IDataDictionaryRepository _dataDictionaryRepository;

        public DataDictionaryController(IDataDictionaryRepository dataDictionaryRepository)
        {
            this._dataDictionaryRepository = dataDictionaryRepository;
        }

        /// <summary>
        /// 创建数据字典
        /// </summary>
        /// <param name="dataDictionaryDto">数据字典对象</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult CreateDataDictionary([FromBody] DataDictionaryDto dataDictionaryDto)
        {
            DataDictionary dataDictionary = _dataDictionaryRepository.CreateDataDictionary(dataDictionaryDto);
            return Ok(dataDictionary);
        }
    }
}
